package com.yiyukongjian.house.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yiyukongjian.house.R;

public class ProcessingBar extends LinearLayout {

//	private ProgressBar mProbar = null;
	private TextView mTextView = null;
	private RelativeLayout mLayout = null;
	public ProcessingBar(Context context) {
		super(context);
	}
	
	public ProcessingBar(Context context, AttributeSet attrs) {
		super(context, attrs);
		LayoutInflater.from(context).inflate(R.layout.processingbar, this, true);
//		setWeightSum(1.0f);
//		mProbar = (ProgressBar) findViewById(R.id.pro_processing);
		mTextView = (TextView) findViewById(R.id.pro_hint_text);
//		mLayout = (RelativeLayout) findViewById(R.id.pro_outer);
				
		TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ProcessingBarWidget);

		final int cnt = array.getIndexCount();
		for(int i = 0; i < cnt; i++){
			int attr = array.getIndex(i);
			int resouceId = -1;
			switch(attr){
			case R.styleable.ProcessingBarWidget_processHintText:
				resouceId = array.getResourceId(R.styleable.ProcessingBarWidget_processHintText,0);
				mTextView.setText(resouceId > 0 ? array.getResources().getText(resouceId) : array.getString(R.styleable.ProcessingBarWidget_processHintText));
				break;
				/*
			case R.styleable.ProcessingBarWidget_isVisible:
				resouceId = array.getInt(R.styleable.ProcessingBarWidget_isVisible,0);
				if(resouceId == 0){
					mLayout.setVisibility(GONE);
				}else if(resouceId == 1){
					mLayout.setVisibility(VISIBLE);
				}else if(resouceId == 2){
					mLayout.setVisibility(INVISIBLE);
				}
				break;
				*/
		    default:
		    	break;
			}
		}				
		array.recycle();
	}
	
	public void setHintProcessingText(String text){
		if(this.mTextView != null){
			this.mTextView.setText(text);
		}
	}
	
//	public void setOuterVisible(int visible){
//		if(this.mLayout != null){
//			this.mLayout.setVisibility(visible);
//		}
//	}

}
